package com.qf.im.controller;


import com.qf.im.base.BaseController;
import com.qf.im.base.R;
import com.qf.im.entity.FriendRequest;
import com.qf.im.entity.vo.RequestHandlerVo;
import com.qf.im.entity.vo.RequestInfoVo;
import com.qf.im.service.FriendRequestService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 好友申请表(FriendRequest)表控制层
 *
 * @author makejava
 * @since 2023-10-30 14:17:03
 */
@RestController
@RequestMapping("/friendRequest")
@Slf4j
public class FriendRequestController extends BaseController<FriendRequestService> {

    /**
     * 新增好友申请
     * @return
     */
    @RequestMapping("/insert")
    public R insert(@Validated FriendRequest friendRequest){
        log.debug("【insert friend request】添加好友申请 - {}", friendRequest);
        return R.succ(getBaseService().save(friendRequest));
    }

    /**
     * 查询对我的申请
     */
    @RequestMapping("/query2myrequest")
    public R query2MyRequest(){
        log.debug("【query to my friend request】查询对我的好友申请...");
        List<RequestInfoVo> requestInfoVos = getBaseService().query2MyRequest();
        return R.succ(requestInfoVos);
    }

    /**
     * 查询当前的 对我的 申请的待处理的数量
     * @return
     */
    @RequestMapping("/query2MeRequestNum")
    public R query2MeRequestNum(){
        return R.succ(getBaseService().queryMeRequestNum());
    }

    /**
     * 好友申请处理的接口
     * @return
     */
    @RequestMapping("/requestHandler")
    public R requestHandler(@Validated RequestHandlerVo requestHandlerVo){
        log.debug("【request handler】好友申请的处理...{}", requestHandlerVo);
        getBaseService().requestHandler(requestHandlerVo);
        return R.succ();
    }
}

